{extend name="platform/base" /}
{block name="main"}
<section class="panel panel-default">
     <header class="panel-heading text-right bg-light">
       <ul class="nav nav-tabs pull-left">
         <li class="active"><a href="#mobile" data-toggle="tab">短信设置</a></li>
       </ul>
       <span class="hidden-sm">邮箱短信</span>
     </header>
                  <div class="panel-body">
                    <div class="tab-content">
                   
                      <div class="tab-pane fade active in" id="mobile">
							<div class="panel-body">
								<form class="form-horizontal" method="get">
									<div class="form-group">
										<label class="col-sm-2 control-label">是否启用</label>
										<div class="col-md-4">
											<label class="switch" style="float:left;margin-right:10px;">
												<input type="checkbox" id="mobile_is_use" {if condition="$mobile_message.is_use=='1'"}checked="checked"{/if}>
												<span></span>
											</label>
											<p style="margin: 5px 0;color:#666;" class="showmessage">当前使用阿里大于短信配置</p>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label">APP_KEY</label>
										<div class="col-md-4">
											<input type="text" class="form-control" id="APP_KEY" value="{$mobile_message['value']['appKey']}">
										</div>
									</div>
									<div class="line line-dashed line-lg pull-in"></div>
									<div class="form-group">
										<label class="col-sm-2 control-label">SECRET_KEY</label>
										<div class="col-md-4">
											<input type="text" class="form-control" id="SECRET_KEY" value="{$mobile_message['value']['secretKey']}">
										</div>
									</div>
									<div class="line line-dashed line-lg pull-in"></div>
									<div class="form-group">
										<label class="col-sm-2 control-label">短信内容签名</label>
										<div class="col-md-4">
											<input type="text" class="form-control" id="FREE_SIGN_NAME" value="{$mobile_message['value']['freeSignName']}">
										</div>
									</div>
									<div class="line line-dashed line-lg pull-in"></div>
									<div class="form-group">
										<label class="col-sm-2 control-label">阿里大鱼用户</label>
										<div class="col-md-4">
											<input type="radio" value="0" name="user_type" id="user_type_old" {if condition="$mobile_message['value']['user_type'] == 0"}checked="checked"{/if} />
											<label for="user_type_old">旧用户</label>
											
											<input type="radio" value="1" name="user_type" id="user_type_new" {if condition="$mobile_message['value']['user_type'] == 1"}checked="checked"{/if} />
											<label for="user_type_new">新用户</label>
											
											<p style="color:#FF8400;font-weight:bold">注:新用户为已入驻阿里云短信</p>
										</div>
									</div>
									<div class="line line-dashed line-lg pull-in"></div>
									<div class="form-group">
										<div class="col-sm-4 col-sm-offset-2">
											<a href="javascript:void(0);" onclick="setMobileMessage()" class="btn btn-primary">保存</a>
										</div>
									</div>
								</form>
							</div>
                      </div>
                   
                    </div>
                  </div>
                </section>


<script>

//设置短信通知
	function setMobileMessage(){
		if($("#mobile_is_use").prop('checked')){
			var is_use = 1;
		}else{
			var is_use = 0;
		}
		var app_key = $("#APP_KEY").val();
		var secret_key = $("#SECRET_KEY").val();
		var free_sign_name = $("#FREE_SIGN_NAME").val();
		var user_type = $("input[name='user_type']:checked").val();//用户类型
		$.ajax({
			type:"post",
			url:"{:__URL('PLATFORM_MAIN/config/setmobilemessage')}",
			data:{
				'is_use':is_use,
				'app_key':app_key,
				'secret_key':secret_key,
				'free_sign_name':free_sign_name,
				'user_type' : user_type
			},
			async:true,
			success:function (data) {
				if (data["code"] > 0) {
					showMessage('success', data["message"],"{:__URL('PLATFORM_MAIN/config/notifyindex')}");
				}else{
					showMessage('error', data["message"]);
				}	
			}
		});
	}
	function testSend(){
		var email_test = $("#email_test").val();
		$.ajax({
			type:"post",
			url:"{:__URL('PLATFORM_MAIN/config/testsend')}",
			data:{
				'email_test':email_test,
			},
			async:true,
			success:function (data) {
				if (data["code"] > 0) {
					showMessage('success', data["message"]);
				}else{
					showMessage('error', data["message"]);
				}	
			}
		});
	}
</script>
{/block}